package com.caregiver.watch.business.data.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @Description: 线程池配置
 * @Author 疆戟
 * @Date 2025/9/14 21:31
 * @Version 1.0
 */
@Configuration
public class ThreadPoolConfiguration {


    @Bean
    public ExecutorService sleepDataCalculationSelectThreadPool() {
        return new ThreadPoolExecutor(
                1,
                1,
                60,
                TimeUnit.SECONDS,
                new LinkedBlockingQueue<>(1000),
                new ThreadPoolExecutor.CallerRunsPolicy());
    }


    /**
     * 睡眠数据计算线程池
     * @return
     */
    @Bean
    public ExecutorService sleepDataCalculationWorkThreadPool() {
        return new ThreadPoolExecutor(
                20,
                20,
                60,
                TimeUnit.SECONDS,
                new LinkedBlockingQueue<>(5000),
                new ThreadPoolExecutor.CallerRunsPolicy());
    }
}
